<?php
    $configPunto = $this->Session->read('configPunto');
    
    $this->Js->JqueryEngine->jQueryObject = '$j';
    echo $this->Html->scriptBlock('var $j = jQuery.noConflict();', array('inline' => false));
    $this->Paginator->options(array('update' => '#dialogoListadoCliente', 'evalScripts' => true, 
        'before' => '$j.fn.show_div_loader()', 
        'complete' => '$j.fn.hide_div_loader()',
        'url' => $url));
    echo "<br/><span class='info-paginador'>{$this->Paginator->counter('Registros: <b>{:start}</b> al <b>{:end}</b> - Total: <b>{:count}</b>')}</span>";
?>
<script type="text/javascript">
    $j(document).on('click', 'tr.selecCli', function(e){
        e.stopImmediatePropagation();
        var idTrPadre = $j(this).prop('id'),
            ced_rif = $j(this).children(":eq(0)").text();
        dialogoCliente.dialog('close');
        var facDir = <?php echo $configPunto['Punto']['fac_dir']; ?>;
        facDir = (facDir == 1) ? 'F' : 'C';
        $j.fn.buscarCliente(e, facDir, 'undefined', idTrPadre, ced_rif);
        return false;
    });
</script>
<table class="tabla-dialogo">
    <tr>
        <th width="140">C&eacute;dula/Rif Cliente</th>
        <th>Nombre Cliente</th>
        <th width="120">Tipo Documento</th>
    </tr>
    <?php if(empty($data)) { ?>
        <tr>
            <td colspan="10" class="centro">No se encontraron registros</td>
        </tr>
    <?php
    } else {
        foreach($data as $valor){ ?>
        <tr id="<?php echo $this->Formulario->id($valor['Cliente']['id']); ?>" class="selecCli" style="height: 34px;">
            <td class="centro"><?php echo $this->Formulario->formatocedula($valor['Cliente']['documento']); ?></td>
            <td><?php echo $valor['Cliente']['nombre']; ?></td>
            <td><?php echo $tipo = ($valor['Cliente']['tipo_doc'] == 'PN') ? 'C&eacute;dula' : 'Rif'; ?></td>
        </tr>
    <?php
        }
    }
    ?>
</table>
<?php
    echo $this->Paginator->first('<< ', array('class' => 'normal')) . ' ';
    echo $this->Paginator->prev('< ', array('class' => 'normal')) . ' ';
    echo $this->Paginator->numbers(array('modulus' => '2', 'class' => 'normal', 'currentClass' => 'actual')) . ' ';
    echo $this->Paginator->next('>', array('class' => 'normal')) . ' ';
    echo $this->Paginator->last('>>', array('class' => 'normal'));
    echo $this->Js->writeBuffer();